/**
 * 自定义函数
 * */


//var funArys = [
//    {
//        id: 1, title: '工时提报', childList: [
//            {
//               id: 101, title: '任务发布', icon: '/h5/imgs/wh009.png', link: '/h5/yw-wh/task.html'
//            },
//            {
//               id: 102, title: '工时录入', icon: '/h5/imgs/wh010.png', link: '/h5/yw-wh/whyw.html'
//            }
//        ]
//    },
//    {
//        id: 2, title: '基础资料', childList: [
//            {
//               id: 201, title: '部门', icon: '/h5/imgs/wh006.png', link: '/h5/yw-basic/depart.html'
//            },
//            {
//               id: 202, title: '项目', icon: '/h5/imgs/wh007.png', link: '/h5/yw-basic/item.html'
//            },
//            {
//               id: 203, title: '工时项', icon: '/h5/imgs/wh008.png', link: '/h5/yw-basic/wh.html'
//            }
//        ]
//    },
//    {
//        id: 3, title: '统计分析', childList: [
//            {
//               id: 301, title: '个人工时汇总', icon: '/h5/imgs/wh005.png', link: '/h5/yw-tongji/?.html'
//            },
//            {
//               id: 302, title: '项目组工时汇总', icon: '/h5/imgs/wh005.png', link: '/h5/yw-tongji/?.html'
//            },
//            {
//               id: 303, title: '所有项目工时汇总', icon: '/h5/imgs/wh005.png', link: '/h5/yw-tongji/?.html'
//            },
//            {
//               id: 304, title: '同比环比数据比较', icon: '/h5/imgs/wh005.png', link: '/h5/yw-tongji/?.html'
//            },
//            {
//               id: 305, title: '图形报表', icon: '/h5/imgs/wh005.png', link: '/h5/yw-tongji/?.html'
//            }
//        ]
//    },
//    {
//        id: 1, title: '系统设置', childList: [
//            {
//               id: 101, title: '人员账号', icon: '/h5/imgs/wh004.png', link: '/h5/yw-sys/staff.html'
//            },
//            {
//               id: 102, title: '角色权限', icon: '/h5/imgs/wh001.png', link: '/h5/yw-sys/role.html'
//            }
//        ]
//    }
//];


//功能列表
function getList(){
    var uinfo = getUserInfo();
    var formData = {
        uid: uinfo.uid, role_id: uinfo.role_id,
    };
    $.ajax({
        type: apiMethod,
        url: apiDomain + 'wsmenu',
        data: formData,
        success: function (res) {
            console.log(res);
            if (res.code != 0) {
                msgPop({msg: '权限错误'});
                return
            }
            msHtml(res.data);
        },
        error: function () {
            console.log('网络错误');
        }
    });
}


//功能字符串
function msHtml(d){
    var h = '', i, ii, childList;
    for (i = 0; i < d.length; i ++) {
        h += '<div class="title">' + d[i].title + '</div>';
        h += '<div class="tlist">';
        childList = d[i].childList;
        for (ii = 0; ii < childList.length; ii ++) {
            h += '<div class="li" onclick="tolink(' + childList[ii].id + ');">';
            h += '<img src="' + childList[ii].icon + '"/> <br>';
            h += childList[ii].title;
            h += '<input type="hidden" id="link' + childList[ii].id + '" value="' + childList[ii].link + '"/>';
            h += '</div>';
        }
        h += '</div>';
    }
    $('#tbody').html(h);
}


//页面跳转
function tolink(v){
    window.location.href = $('#link' + v).val();
}